package Ioperate;

import book.BookList;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class BrowwedBook implements Ioperate{
    public void work(BookList bookList){
        Scanner scanner = new Scanner(System.in);
        int count = bookList.getSize();
        System.out.println("请输入要借阅的书名：");
        String name = scanner.nextLine();

        for (int i = 0; i < count; i++) {
            if(bookList.getBooks(i).getName().equals(name)){
                if(bookList.getBooks(i).isaBoolean()){
                    System.out.println("此书已被借出！");
                    System.out.println();
                    return ;
                }else {
                    bookList.getBooks(i).setaBoolean(true);
                    System.out.println(bookList.getBooks(i).getName()+"借出成功!");
                    System.out.println();
                    return ;
                }
            }
        }
        System.out.println("此书不存在！");
    }
}
